import UserAPI from '@/api/user'
import type { UserQuery } from '@/api/user/model'
import type { IContentConfig } from '@/components/PageContent/index.vue'

const contentConfig: IContentConfig<UserQuery> = {
  pageName: 'sys:user',
  table: {
    highlightCurrentRow: true,
  },
  indexAction(params) {
    if ('createAt' in params) {
      const createAt = params.createAt as string[]
      params.startTime = createAt[0]
      params.endTime = createAt[1]
      delete params.createAt
    }
    return UserAPI.getPage(params)
  },
  deleteAction: UserAPI.deleteByIds,
  exportAction: UserAPI.export,
  pk: 'id',
  toolbar: [
  ],
  cols: [
    {
      prop: 'nickname',
      label: '用户编号',
      width: '140px',
      align: 'center',
    },
    {
      prop: 'nickname',
      label: '头像',
      width: '140px',
      align: 'center',
    },
    {
      prop: 'nickname',
      label: '昵称',
      width: '140px',
      align: 'center',
    },
    {
      prop: 'nickname',
      label: '账号',
      width: '140px',
      align: 'center',
    },
    {
      prop: 'nickname',
      label: '手机号码',
      width: '140px',
      align: 'center',
    },
    {
      prop: 'nickname',
      label: '注册来源',
      width: '140px',
      align: 'center',
    },
    {
      prop: 'nickname',
      label: '注册时间',
      width: '140px',
      align: 'center',
    },
    {
      prop: 'nickname',
      label: '会员类型',
      width: '140px',
      align: 'center',
    },
    {
      prop: 'nickname',
      label: '亲子账号',
      width: '140px',
      align: 'center',
    },
    {
      prop: 'nickname',
      label: '现金账号',
      width: '140px',
      align: 'center',
    },
    {
      prop: 'nickname',
      label: '金币账号',
      width: '140px',
      align: 'center',
    },
    {
      prop: 'nickname',
      label: '积分',
      width: '140px',
      align: 'center',
    },
    {
      prop: 'nickname',
      label: '会员状态',
      width: '140px',
      align: 'center',
      templet: 'custom',
      slotName: 'status',
    },
    {
      label: '操作',
      fixed: 'right',
      width: 240,
      templet: 'tool',
      operat: [
        {
          name: 'reset_pwd',
          auth: 'password:reset',
          text: '会员详情',
        },
        {
          name: 'reset_pwd',
          auth: 'password:reset',
          text: '充值金币',
        },
        {
          name: 'reset_pwd',
          auth: 'password:reset',
          text: '发放优惠券',
        },
      ],
    },
  ],
}

export default contentConfig
